﻿
Public Class MustHaveValueValidationRule
    Inherits ValidationRule
    Private _Label As String
    Public Property Label() As String
        Get
            Return _Label
        End Get
        Set(ByVal value As String)
            _Label = value
        End Set
    End Property

    Public Overrides Function Validate(ByVal value As Object, ByVal cultureInfo As System.Globalization.CultureInfo) As System.Windows.Controls.ValidationResult
        Dim stringValue As String = TryCast(value, String)
        If String.IsNullOrEmpty(stringValue) Then
            Return New ValidationResult(False, String.Format("Please enter a value for {0}", Label))
        End If
        Return ValidationResult.ValidResult
    End Function
End Class
